let str = 'abcde';

function func(str) {
    if (str.length < 8 && str.length > 16) {
        return 'NG';
    }
    let reg1 = /[\d]/g;
    let reg2 = /[a-z]/g;
    let reg3 = /[A-Z]/g;
    let reg4 = /[~!@#$%^&*()_+-=\{\}\[\]\\\";:,.\/\|\?`]/g;
    let count = 0;
    if (reg1.test(str)) {
        count++;
    }
    if (reg2.test(str)) {
        count++;
    }
    if (reg3.test(str)) {
        count++;
    }
    if (reg4.test(str)) {
        count++;
    }
    if (count < 2) {
        return 'NG';
    }
}

console.log(func(str));